// src/main/java/com/ibuu/demos/controller/PayConrtroller.java
package com.ibuu.demos.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibuu.demos.pojo.Details;
import com.ibuu.dto.OrderDTO;
import com.ibuu.dto.PayRequest;
import com.ibuu.demos.service.CategoriesService;
import com.ibuu.demos.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/pay")
public class PayConrtroller {
    @Autowired
    private PayService payService;
    @Autowired
    private CategoriesService   categoriesService;

    @PostMapping("/buy")
    public void pay(@RequestBody PayRequest payRequest, HttpServletRequest request) {

        payService.pay(request, payRequest);
    }
    //查询订单
//    @GetMapping("/get")
//    public List<Details> get(HttpServletRequest request) {
//        List<Details> details = categoriesService.getDetails(request);
//        return details;
//    }

    @GetMapping("/get")
 public Page<OrderDTO> get(HttpServletRequest request, int pageNum, int pageSize) {
    Page<OrderDTO> details = categoriesService.getDetails(request, pageNum, pageSize);
    return details;
}
}